import React from "react"
import useLogin from "../hooks/useLogin"
import { navigate } from "gatsby"
export default function PrivateRoute(props) {
  const [isLogin, loading] = useLogin()
  console.log([isLogin, loading])
  if (isLogin) {
    const { component: Component, ...restProps } = props
    return <Component {...restProps} />
  }
  navigate("/login")
  return null
}
